用户工具

站点工具

导航栏

基本语法


交流留言

wiki:dokuwiki:dokuwiki force https



Dokuwiki force https

在主题/main.php的开头加入以下代码:

if ($_SERVER[HTTPS]!="on") { 
 
$strURIName=$_SERVER['SERVER_NAME'] . getenv("REQUEST_URI"); 
 
// The function 'getenv' does not work if your Server API is ASAPI (IIS). So, try to don't use getenv('REMOTE_ADDR'), but: 
// $_SERVER["REMOTE_ADDR"]. $strURIName=$_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI']; 
 
header ("Location: https://$strURIName"); 
 
// If it doesn't work for you and you need to troubleshoot your php code, uncomment below to find out about your particular server variables.
/*
  echo "<b>_SERVER Variables from $_SERVER</b><br><br>";
  reset($_SERVER);
  while (list ($key, $val) = each ($_SERVER)) {
  print $key . " = " . $val . "<br>"; }   
*/
}

后一篇末篇

wiki/dokuwiki/dokuwiki force https.txt · 最后更改: 2020/05/16 19:50 (外部编辑)

oeffentlich